
#import "ChartOfMatrixInspector.h"
#import "ChartOfMatrix.h"

@implementation ChartOfMatrixInspector

- init
{
    char buf[MAXPATHLEN+1];
    id bundle;
    
    self = [super init];
    
    bundle = [NXBundle bundleForClass:[ChartOfMatrixInspector class]];
    [bundle getPath:buf
    	forResource:"ChartOfMatrixInspector" ofType:"nib"];
    
    [NXApp loadNibFile: buf owner:self withNames:NO];
    
    [self revert:self];
    return self;
}

- doAutoScale:sender
{
    [object takeAutoScaleStateFrom:sender];
    return self;
}

- doBackgroundColor:sender
{
    [object setBackgroundColor:[sender color]];
    return self;
}

- doHighlightColor:sender
{
    [object setHighlightColor:[sender color]];
    return self;
}

- doBorderType:sender
{
    [object takeBorderTypeFrom:sender];
    return self;
}

- doFrameState:sender
{
    [object takeFrameStateFrom:sender];
    return self;
}

- doGraphType:sender
{
    [object setGraphType:[sender selectedTag]];
    return self;
}

- doHMargin:sender
{
    [object takeHMarginFrom:sender];
    return self;
}

- doMaxValue:sender
{
    [object takeMaxValueFrom:sender];
    return self;
}

- doMinValue:sender
{
    [object takeMinValueFrom:sender];
    return self;
}

- doPrototypeNum:sender
{
    [object takeNumProtosFrom:sender];
    return self;
}

- doRandomBarColorsState:sender
{
    [object takeRandomColorStateFrom:sender];
    return self;
}

- doVMargin:sender
{
    [object takeVMarginFrom:sender];
    return self;
}

/* ======================================================================
 *
 * ====================================================================== */
 

- (BOOL)wantsButtons
{
    return NO; }

- revert:sender {
    [hMarginOutlet setFloatValue:[object hMargin]];
    [vMarginOutlet setFloatValue:[object vMargin]];
    [frameStateOutlet setState:[object frameState]];
    [minValueOutlet setDoubleValue:[object minValue]];
    [maxValueOutlet setDoubleValue:[object maxValue]];
    [autoScaleOutlet setState:[object autoScale]];
    [graphTypeOutlet 	selectCellWithTag:[object graphType]];
    [prototypeNumOutlet setIntValue:[object numProtos]];
    [borderTypeOutlet	selectCellWithTag:[object borderType]];
    [backgroundColorOutlet setColor:[object backgroundColor]];
    [highlightColorOutlet setColor: [object highlightColor]];
    [randomBarColorsOutlet setState: [object isRandomBarColorEnabled]];

    return [super revert:sender];
}

- ok:sender {
    
    [self doAutoScale:autoScaleOutlet];
    [self doBackgroundColor:backgroundColorOutlet];
    [self doBorderType:borderTypeOutlet];
    [self doFrameState:frameStateOutlet];
    [self doGraphType:graphTypeOutlet];
    [self doHighlightColor:highlightColorOutlet];
    [self doHMargin:hMarginOutlet];
    [self doMaxValue:maxValueOutlet];
    [self doMinValue:minValueOutlet];
    [self doPrototypeNum:prototypeNumOutlet];
    [self doRandomBarColorsState:randomBarColorsOutlet];
    [self doVMargin:vMarginOutlet];
    
    return [super ok:sender];
}

@end
